{extend name="public/base" /}

{block name="title"}<title>{$Think.lang.list}</title>{/block}

{block name="pjax_container"}
<section class="content-header">
    <h1>{$Think.lang.d_title}{$Think.lang.list}</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <div style="float: right;">
                        <form action="{:search_url('search')}" method="GET" pjax-search="">
                            <div class="input-group input-group-sm col-lg-4" style="float: right;">
                                <input type="text" name="search" class="form-control pull-right" value="{:input('get.search')}" placeholder="搜索账户名称 / 姓名 / 电话" />
                                <div class="input-group-btn"><button type="submit" class="btn btn-default sreachs"><i class="fa fa-search"></i></button></div>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover table-sort">
                        <tr>
                            <th width="35"><input type="checkbox" class="minimal checkbox-toggle"></th>
                            <th>{$Think.lang.id}{:table_sort('id')}</th>
                            <th>{$Think.lang.agentname}</th>
                            <th>{$Think.lang.name}</th>
                            <th>{$Think.lang.mobile}</th>
                            <th>{$Think.lang.level}</th>
                            <th>{$Think.lang.reg_time}{:table_sort('reg_time')}</th>
                            <th>{$Think.lang.end_time}{:table_sort('end_time')}</th>
                            <th>{$Think.lang.status}{:table_sort('status')}</th>
                            <th width="124">{$Think.lang.action}</th>
                        </tr>
                        {volist name="dataList" id="vo"}
                        <tr>
                            <td><input type="checkbox" name="id[]" value="{$vo.id}" class="minimal"></td>
                            <td>{$vo.id}</td>
                            <td>{$vo.agentname}</td>
                            <td>{$vo.name}</td>
                            <td>{$vo.mobile}</td>
                            <td>{$vo->AgentLevel->level_name}</td>
                            <td>{$vo.reg_time}</td>
                            <td>{$vo.end_time}</td>
                            <td>{$vo.status}</td>
                            <td>
                                {:auth_action(CONTROLLER_NAME.'/recover', 'box', lang('recover'), $vo.id)}
                            </td>
                        </tr>
                        {/volist}
                    </table>
                </div>
                <div class="box-footer clearfix">
                    {$dataList->render()|raw}
                </div>
            </div>
        </div>
    </div>
</section>
<script type="text/javascript">
$(function(){
    /*ajax页面加载icheck，有该控件的页面才需要*/
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
        checkboxClass: 'icheckbox_minimal-blue',
        radioClass: 'iradio_minimal-blue'
    });
    
    /*全选-反选*/
    $('.checkbox-toggle').on('ifChecked', function(event){
        var _this = $(this);
        var _table = _this.closest('.table');
        _table.find("tr td input[type='checkbox']").iCheck("check");
    });
    $('.checkbox-toggle').on('ifUnchecked', function(event){
        var _this = $(this);
        var _table = _this.closest('.table');
        _table.find("tr td input[type='checkbox']").iCheck("uncheck");
    });
    
    $('.editable').editable({
        emptytext: "empty",
        params: function(params) {      //参数
            var data = {};
            data['id'] = params.pk;
            data[params.name] = params.value;
            return data;
        },
        success: function(response, newValue) {
            var res = $.parseJSON( response );
            if(res.status == 1){
                toastr.success(res.info);
            }else{
                return res.info;
            }
        }
    });
})
</script>
{/block}